home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / arrays / vsflex / fmerge.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-06-15  |  10.2 KB  |  331 lines

  1. VERSION 2.00
  2. Begin Form fMerge 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Summary Sheet"
  6.    ClientHeight    =   5745
  7.    ClientLeft      =   915
  8.    ClientTop       =   1155
  9.    ClientWidth     =   8115
  10.    Height          =   6150
  11.    Left            =   855
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   5745
  14.    ScaleWidth      =   8115
  15.    Top             =   810
  16.    Width           =   8235
  17.    Begin OptionButton Option1 
  18.       BackColor       =   &H00C0C0C0&
  19.       Caption         =   "VSFlex"
  20.       FontBold        =   -1  'True
  21.       FontItalic      =   0   'False
  22.       FontName        =   "Arial"
  23.       FontSize        =   9.75
  24.       FontStrikethru  =   0   'False
  25.       FontUnderline   =   0   'False
  26.       ForeColor       =   &H00000000&
  27.       Height          =   330
  28.       Index           =   1
  29.       Left            =   450
  30.       TabIndex        =   8
  31.       Top             =   1710
  32.       Width           =   1245
  33.    End
  34.    Begin Frame Frame1 
  35.       BackColor       =   &H00C0C0C0&
  36.       Enabled         =   0   'False
  37.       FontBold        =   0   'False
  38.       FontItalic      =   0   'False
  39.       FontName        =   "MS Sans Serif"
  40.       FontSize        =   8.25
  41.       FontStrikethru  =   0   'False
  42.       FontUnderline   =   0   'False
  43.       ForeColor       =   &H00FF0000&
  44.       Height          =   1500
  45.       Left            =   360
  46.       TabIndex        =   4
  47.       Top             =   1740
  48.       Width           =   1935
  49.       Begin CheckBox chkPictures 
  50.          BackColor       =   &H00C0C0C0&
  51.          Caption         =   "Add Pictures"
  52.          Enabled         =   0   'False
  53.          FontBold        =   0   'False
  54.          FontItalic      =   0   'False
  55.          FontName        =   "MS Sans Serif"
  56.          FontSize        =   8.25
  57.          FontStrikethru  =   0   'False
  58.          FontUnderline   =   0   'False
  59.          ForeColor       =   &H00000000&
  60.          Height          =   225
  61.          Left            =   390
  62.          TabIndex        =   7
  63.          Top             =   420
  64.          Width           =   1245
  65.       End
  66.       Begin CheckBox chkMergeCells 
  67.          BackColor       =   &H00C0C0C0&
  68.          Caption         =   "Merge Cells"
  69.          Enabled         =   0   'False
  70.          FontBold        =   0   'False
  71.          FontItalic      =   0   'False
  72.          FontName        =   "MS Sans Serif"
  73.          FontSize        =   8.25
  74.          FontStrikethru  =   0   'False
  75.          FontUnderline   =   0   'False
  76.          ForeColor       =   &H00000000&
  77.          Height          =   225
  78.          Left            =   405
  79.          TabIndex        =   6
  80.          Top             =   675
  81.          Width           =   1350
  82.       End
  83.       Begin CommandButton Command1 
  84.          BackColor       =   &H00C0C0C0&
  85.          Caption         =   "Drag && Drop"
  86.          Enabled         =   0   'False
  87.          FontBold        =   0   'False
  88.          FontItalic      =   0   'False
  89.          FontName        =   "MS Sans Serif"
  90.          FontSize        =   8.25
  91.          FontStrikethru  =   0   'False
  92.          FontUnderline   =   0   'False
  93.          Height          =   345
  94.          Left            =   390
  95.          TabIndex        =   5
  96.          Top             =   1020
  97.          Width           =   1095
  98.       End
  99.    End
  100.    Begin OptionButton Option1 
  101.       BackColor       =   &H00C0C0C0&
  102.       Caption         =   "Plain Grid"
  103.       FontBold        =   -1  'True
  104.       FontItalic      =   0   'False
  105.       FontName        =   "Arial"
  106.       FontSize        =   9.75
  107.       FontStrikethru  =   0   'False
  108.       FontUnderline   =   0   'False
  109.       ForeColor       =   &H00000000&
  110.       Height          =   330
  111.       Index           =   0
  112.       Left            =   465
  113.       TabIndex        =   3
  114.       Top             =   1350
  115.       Value           =   -1  'True
  116.       Width           =   1515
  117.    End
  118.    Begin vsFlexArray fa 
  119.       BackColor       =   &H00C0C0C0&
  120.       BackColorFixed  =   &H00000000&
  121.       Cols            =   4
  122.       DragIcon        =   FMERGE.FRX:0000
  123.       FixedCols       =   0
  124.       FocusRect       =   0  'None
  125.       FontBold        =   0   'False
  126.       FontItalic      =   0   'False
  127.       FontName        =   "Arial"
  128.       FontSize        =   9.75
  129.       FontStrikethru  =   0   'False
  130.       FontUnderline   =   0   'False
  131.       ForeColorFixed  =   &H0000FF00&
  132.       FormatString    =   "^Region            |^Product       |^Employee    |>Sales            "
  133.       GridColor       =   &H00008080&
  134.       GridLines       =   2  'Inset
  135.       Height          =   4650
  136.       HighLight       =   0  'Never
  137.       Left            =   2700
  138.       RowHeightMin    =   420
  139.       Rows            =   11
  140.       ScrollBars      =   0  'None
  141.       ScrollTrack     =   -1  'True
  142.       TabIndex        =   0
  143.       Top             =   810
  144.       Width           =   5130
  145.    End
  146.    Begin Label Label2 
  147.       Alignment       =   2  'Center
  148.       BackColor       =   &H00C0C0C0&
  149.       BackStyle       =   0  'Transparent
  150.       Caption         =   "See summary as:"
  151.       FontBold        =   -1  'True
  152.       FontItalic      =   0   'False
  153.       FontName        =   "Arial"
  154.       FontSize        =   13.5
  155.       FontStrikethru  =   0   'False
  156.       FontUnderline   =   0   'False
  157.       ForeColor       =   &H00000000&
  158.       Height          =   585
  159.       Index           =   0
  160.       Left            =   270
  161.       TabIndex        =   2
  162.       Top             =   675
  163.       Width           =   1935
  164.    End
  165.    Begin Image flag 
  166.       Height          =   480
  167.       Index           =   3
  168.       Left            =   810
  169.       Picture         =   FMERGE.FRX:0302
  170.       Top             =   4860
  171.       Visible         =   0   'False
  172.       Width           =   480
  173.    End
  174.    Begin Image flag 
  175.       Height          =   480
  176.       Index           =   2
  177.       Left            =   195
  178.       Picture         =   FMERGE.FRX:0604
  179.       Top             =   4875
  180.       Visible         =   0   'False
  181.       Width           =   480
  182.    End
  183.    Begin Image flag 
  184.       Height          =   480
  185.       Index           =   1
  186.       Left            =   2010
  187.       Picture         =   FMERGE.FRX:0906
  188.       Top             =   4875
  189.       Visible         =   0   'False
  190.       Width           =   480
  191.    End
  192.    Begin Image flag 
  193.       Height          =   480
  194.       Index           =   0
  195.       Left            =   1335
  196.       Top             =   4905
  197.       Visible         =   0   'False
  198.       Width           =   480
  199.    End
  200.    Begin Label Label1 
  201.       Alignment       =   2  'Center
  202.       BackColor       =   &H00000000&
  203.       Caption         =   "Summary"
  204.       FontBold        =   -1  'True
  205.       FontItalic      =   0   'False
  206.       FontName        =   "Arial"
  207.       FontSize        =   24
  208.       FontStrikethru  =   0   'False
  209.       FontUnderline   =   0   'False
  210.       ForeColor       =   &H0000FFFF&
  211.       Height          =   585
  212.       Left            =   2670
  213.       TabIndex        =   1
  214.       Top             =   165
  215.       Width           =   5175
  216.    End
  217. Option Explicit
  218. Sub chkMergeCells_Click ()
  219.       fa.MergeCells = IIf(fa.MergeCells = 0, 2, 0)
  220. End Sub
  221. Sub chkPictures_Click ()
  222.    Dim i%
  223.    fa.Row = 0
  224.    For i = 0 To 3
  225.       ' find "Country" column
  226.       fa.Col = i
  227.       If Trim(fa) = "Country" Then Exit For
  228.    Next i
  229.    If chkPictures Then
  230.       DoAddFlagsToColumn (fa.Col)
  231.    Else
  232.       DoRemoveFlagsFrom (fa.Col)
  233.    End If
  234. End Sub
  235. Sub Command1_Click ()
  236.    MsgBox "Drag and drop column's headers and see the data automatically rearranged"
  237. End Sub
  238. Sub DoAddFlagsToColumn (Col)
  239.    Dim i%
  240.    fa.Col = Col
  241.    For i = 1 To NUMREC - 1
  242.       fa.Row = i
  243.       fa.CellPictureAlignment = 1
  244.       Select Case fa
  245.          Case "USA": fa.CellPicture = flag(1)
  246.          Case "Canada": fa.CellPicture = flag(2)
  247.          Case "Germany": fa.CellPicture = flag(3)
  248.       End Select
  249.    Next i
  250. End Sub
  251. Sub DoFillData ()
  252.    Dim i%
  253.    ' from structure to FlexArray
  254.     For i = 0 To NUMREC - 1
  255.       fa.TextArray(fai(i, 0)) = MyData(i).Country
  256.       fa.TextArray(fai(i, 1)) = MyData(i).Product
  257.       fa.TextArray(fai(i, 2)) = MyData(i).Type
  258.       fa.TextArray(fai(i, 3)) = Format$(MyData(i).Sales, "##.00")
  259.       If Val(MyData(i).Sales) < 0 Then
  260.          fa.Row = i
  261.          fa.Col = 3
  262.          fa.CellForeColor = RGB(255, 0, 0)     ' negatives in red
  263.       End If
  264.     Next
  265. End Sub
  266. Sub DoInitialSettings ()
  267.     Dim i%
  268.     fa.Rows = NUMREC
  269.     fa.ColAlignment(0) = 7       ' Align CenterLeft
  270.     fa.Row = 0
  271.     ' change fonts on title Row
  272.     For i = 0 To fa.Cols - 1
  273.       fa.Col = i
  274.       fa.CellFontSize = 14
  275.       fa.CellAlignment = 4       ' Center Center
  276.     Next i
  277.     ' merge only first 3 columns
  278.     fa.MergeCol(0) = True
  279.     fa.MergeCol(1) = True
  280.     fa.MergeCol(2) = True
  281. End Sub
  282. Sub DoRemoveFlagsFrom (Col%)
  283.    Dim i%
  284.    For i = 1 To NUMREC - 1
  285.       fa.Row = i
  286.       fa.CellPicture = flag(0)      ' No Flag
  287.    Next i
  288. End Sub
  289. Sub DoSort ()
  290.     fa.Col = 0
  291.     fa.ColSel = fa.Cols - 1
  292.     fa.Sort = 1      'numeric ascendent
  293. End Sub
  294. Sub fa_DragDrop (Source As Control, X As Single, Y As Single)
  295.     If fa.Tag = "" Then Exit Sub
  296.     fa.Redraw = False
  297.     fa.ColPosition(Val(fa.Tag)) = fa.MouseCol
  298.     DoSort
  299.     fa.Redraw = True
  300. End Sub
  301. Sub fa_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  302.     Debug.Print "dn"
  303.     fa.Tag = ""
  304.     If fa.MouseRow <> 0 Then Exit Sub
  305.     fa.Tag = Str(fa.MouseCol)
  306.     fa.Drag 1
  307. End Sub
  308. Sub fa_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  309. Debug.Print "up"
  310. End Sub
  311. Function fai (r%, c%) As Integer
  312.     fai = c + fa.Cols * r
  313. End Function
  314. Sub Form_Load ()
  315.     DoInitialSettings
  316.     DoGetData
  317.     DoFillData
  318.     DoSort
  319. End Sub
  320. Sub Option1_Click (Index As Integer)
  321.    ' enable and disable controls
  322.    chkPictures.Enabled = Not chkPictures.Enabled
  323.    chkMergeCells.Enabled = Not chkMergeCells.Enabled
  324.    command1.Enabled = Not command1.Enabled
  325.    frame1.Enabled = Not frame1.Enabled
  326.    fa.Redraw = False
  327.    chkPictures.Value = Index
  328.    chkMergeCells.Value = Index
  329.    fa.Redraw = True
  330. End Sub
  331.